//
//  ZZNewsChannelCollectionViewCell.m
//  ZZNews
//
//  Created by 周英培 on 16/7/27.
//  Copyright © 2016年 周英培. All rights reserved.
//

#import "ZZNewsChannelCollectionViewCell.h"

@interface ZZNewsChannelCollectionViewCell ()

@property (nonatomic,strong) UILabel *tnameLabel;

@end

@implementation ZZNewsChannelCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.tnameLabel = [[UILabel alloc] init];
        
        self.tnameLabel.textAlignment = NSTextAlignmentCenter;
        
        [self.contentView addSubview:self.tnameLabel];
        
    }
    return self;
}

- (void)setChannelModel:(ZZNewsChannelModel *)channelModel {

    _channelModel = channelModel;
    
    self.tnameLabel.text = channelModel.tname;
    
    //MARK:文字随着点击状态的改变的改变
    if (self.selected) {
        
        self.tnameLabel.font = [UIFont systemFontOfSize:18];
        
        self.tnameLabel.textColor = [UIColor redColor];
        
        [self.tnameLabel sizeToFit];
        
        self.tnameLabel.frame = CGRectMake((self.contentView.bounds.size.width - self.tnameLabel.bounds.size.width) / 2, (self.contentView.bounds.size.height - self.tnameLabel.bounds.size.height) / 2, self.tnameLabel.bounds.size.width, self.tnameLabel.bounds.size.height);

        
    } else {
    
        self.tnameLabel.font = [UIFont systemFontOfSize:14];
        
        self.tnameLabel.textColor = [UIColor blackColor];
        
        [self.tnameLabel sizeToFit];
        
        self.tnameLabel.frame = CGRectMake((self.contentView.bounds.size.width - self.tnameLabel.bounds.size.width) / 2, (self.contentView.bounds.size.height - self.tnameLabel.bounds.size.height) / 2, self.tnameLabel.bounds.size.width, self.tnameLabel.bounds.size.height);

    
    }
    
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.tnameLabel.frame = CGRectMake((self.contentView.bounds.size.width - self.tnameLabel.bounds.size.width) / 2, (self.contentView.bounds.size.height - self.tnameLabel.bounds.size.height) / 2, self.tnameLabel.bounds.size.width, self.tnameLabel.bounds.size.height);
    
}

@end
